Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-37029: keep usable_arenas in sorted order without searching #13612

Merged
merged 5 commits into from
Jun 1, 2019

Conversation

tim-one
Copy link
Member

@tim-one tim-one commented May 28, 2019

This adds a vector of "search fingers" so that usable_arenas can be kept in sorted order (by number of free pools) via constant-time operations instead of linear search.

This should reduce worst-case time for reclaiming a great many objects from O(A**2) to O(A), where A is the number of arenas.

https://bugs.python.org/issue37029

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks neat, just a comment.

@@ -1172,6 +1189,9 @@ static struct arena_object* unused_arena_objects = NULL;
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment documenting that they are sorted in number of free pools?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not, unless you feel strongly about it. This has been documented all along, but up where the main explanation of arenas lives (look at the comment block about usable_arenas at line 1150).

There are a bunch of moving parts here, and the style of the file is to give long-ish English explanations in uninterrupted comment blocks, with only the briefest of memory-jogging comments on declaration lines.

@tim-one tim-one merged commit 1c263e3 into python:master Jun 1, 2019
@bedevere-bot
Copy link

@tim-one: Please replace # with GH- in the commit message next time. Thanks!

@tim-one tim-one deleted the remove-arena-search branch June 1, 2019 02:30
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…on#13612)

This adds a vector of "search fingers" so that usable_arenas can be kept in sorted order (by number of free pools) via constant-time operations instead of linear search.

This should reduce worst-case time for reclaiming a great many objects from O(A**2) to O(A), where A is the number of arenas.  See bpo-37029.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants